package main

import "fmt"

type ByteCounter int

func (c *ByteCounter) Write(p []byte)  (int, error) {
	*c += ByteCounter(len(p))
	return len(p), nil
}

type IntSet struct {}

func (*IntSet) String() string {
	return "string"
}

func main() {

	var b ByteCounter
	writer, err := b.Write([]byte("hello"))
	if err != nil {
		return
	}
	fmt.Println(writer) // 5
	b = 0
	name := "hello"
	fmt.Fprintf(&b, "%s world", name) // Fprintf方法可以调用Write()方法
	fmt.Println(b) // 11

	var s IntSet
	var _ = s.String()
	var _ fmt.Stringer = &s
	//var _ fmt.Stringer = s
}
